var express = require('express');
var router = express.Router();
const { uploadFiles } = require('../utils/handleFiles');

router.post('/uploadImages', function (req, res, next) {
    // 图片上传
    const uploadImages = uploadFiles({
        path: './public/temp',
        key: 'file',
        size: 5000
    });
    // 获取图片上传的结果
    uploadImages(req, res, err => {
        if (err) {
            console.log('图片上传失败 ----------------------------------');
            console.log(err);
        } else {
            console.log('图片上传成功');
            console.log(req.files);
            res.send({
                message: '图片上传成功',
                status: 1,
                data: req.files.map(item => item.filename)
            })
        }
    })
});

module.exports = router;